home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / CLASSSRC.PAK / LOCALECO.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  2KB  |  69 lines

  1. //----------------------------------------------------------------------------
  2. // Borland WinSys Library
  3. // Copyright (c) 1994, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   5.6  $
  6. //
  7. // TLocaleString default NLS compare function - used only if non-OLE2
  8. //----------------------------------------------------------------------------
  9. #include <winsys/pch.h>
  10. #include <winsys/lclstrng.h>
  11. #include <tchar.h>
  12.  
  13. #if defined(BI_PLAT_WIN32)
  14.  
  15. TLangId
  16. TLocaleString::GetSystemLangId()
  17. {
  18.   return ::GetSystemDefaultLangID();
  19. }
  20.  
  21. TLangId
  22. TLocaleString::GetUserLangId()
  23. {
  24.   return ::GetUserDefaultLangID();
  25. }
  26.  
  27. int
  28. TLocaleString::CompareLang(const _TCHAR far* s1, const _TCHAR far* s2, TLangId lang)
  29. {
  30.   typedef int (WINAPI *TCompareStringA)(LCID, DWORD, LPCSTR, int, LPCSTR, int);
  31.  
  32.   static int (WINAPI *compareStringA)(LCID, DWORD, LPCSTR, int, LPCSTR, int) =
  33.     (TCompareStringA)::GetProcAddress(::GetModuleHandle("kernel32"), "CompareStringA");
  34.  
  35.   // Use CompareStringA if it is available
  36.   //
  37.   if (compareStringA)
  38.     return compareStringA(lang, NORM_IGNORECASE | NORM_IGNORENONSPACE,
  39.                           s1,-1, s2,-1) - 2;
  40.  
  41.   // Otherwise just use RTL function
  42.   //
  43.   return _tcsicmp(s1, s2);  // only permissible if not an OLE application
  44. }
  45.  
  46. #elif defined(BI_PLAT_WIN16)
  47.  
  48. #include <string.h>
  49.  
  50. TLangId
  51. TLocaleString::GetSystemLangId()
  52. {
  53.   return 0x409;  // US English if no OLE or Win32 support
  54. }
  55.  
  56. TLangId
  57. TLocaleString::GetUserLangId()
  58. {
  59.   return 0x409;  // US English if no OLE or Win32 support
  60. }
  61.  
  62. int
  63. TLocaleString::CompareLang(const _TCHAR far* s1, const _TCHAR far* s2, TLangId)
  64. {
  65.   return _fstricmp(s1, s2);  // only permissible if not an OLE application
  66. }
  67.  
  68. #endif
  69.